<?php

/**
 * Player form base class.
 *
 * @method Player getObject() Returns the current form's model object
 *
 * @package    raidpoints
 * @subpackage form
 * @author     David Driscoll
 * @version    SVN: $Id: sfDoctrineFormGeneratedTemplate.php 24171 2009-11-19 16:37:50Z Kris.Wallsmith $
 */
abstract class BasePlayerForm extends BaseFormDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'id'          => new sfWidgetFormInputHidden(),
      'name'        => new sfWidgetFormInputText(),
      'fullname'    => new sfWidgetFormInputText(),
      'altid'       => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Player'), 'add_empty' => false)),
      'guildedflag' => new sfWidgetFormInputCheckbox(),
      'safeflag'    => new sfWidgetFormInputCheckbox(),
      'classid'     => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('PClass'), 'add_empty' => false)),
      'genderid'    => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Gender'), 'add_empty' => false)),
      'raceid'      => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Race'), 'add_empty' => false)),
      'rankid'      => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Rank'), 'add_empty' => false)),
      'created_by'  => new sfWidgetFormInputText(),
      'updated_by'  => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('sfGuardUser'), 'add_empty' => false)),
    ));

    $this->setValidators(array(
      'id'          => new sfValidatorDoctrineChoice(array('model' => $this->getModelName(), 'column' => 'id', 'required' => false)),
      'name'        => new sfValidatorString(array('max_length' => 50)),
      'fullname'    => new sfValidatorString(array('max_length' => 50)),
      'altid'       => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('Player'))),
      'guildedflag' => new sfValidatorBoolean(array('required' => false)),
      'safeflag'    => new sfValidatorBoolean(array('required' => false)),
      'classid'     => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('PClass'))),
      'genderid'    => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('Gender'))),
      'raceid'      => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('Race'))),
      'rankid'      => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('Rank'))),
      'created_by'  => new sfValidatorInteger(),
      'updated_by'  => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('sfGuardUser'))),
    ));

    $this->validatorSchema->setPostValidator(
      new sfValidatorAnd(array(
        new sfValidatorDoctrineUnique(array('model' => 'Player', 'column' => array('name'))),
        new sfValidatorDoctrineUnique(array('model' => 'Player', 'column' => array('fullname'))),
      ))
    );

    $this->widgetSchema->setNameFormat('player[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'Player';
  }

}
